<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>新增班级</title>
  <link rel="icon" href="favicon.ico" type="${pageContext.request.contextPath}/assert/image/ico">
  <link href="${pageContext.request.contextPath}/assert/css/bootstrap.min.css" rel="stylesheet">
  <link href="${pageContext.request.contextPath}/assert/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="${pageContext.request.contextPath}/assert/css/style.min.css" rel="stylesheet">
</head>
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <%--抽取公共部分进行封装起来，增加代码的复用性，减少代码的冗余！--%>
    <jsp:include page="_aside_header.jsp"></jsp:include>
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-12">
            <div class="card">
              <div class="card-body">
                <form  id="myform"   action="${pageContext.request.contextPath}/clazz?r=add" method="post">
                  <div class="form-group">
                    <label>班级编号</label>
                    <input class="form-control" type="text"  name="clazzno" placeholder="请输入班级编号..">
                  </div>
                  <div class="form-group">
                    <label>班级名</label>
                    <input class="form-control" type="text"  name="name" placeholder="请输入班级班级名..">
                  </div>
                  <div class="form-group">
                    <button class="btn btn-primary" type="submit">提交</button>
                  </div>
                </form>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<jsp:include page="_js.jsp"></jsp:include>
<script type="text/javascript">
  $(document).ready(function (e){
    $("#myform").submit(function (event){
      event.preventDefault();
      lightyear.loading('show');//显示加载
      // 假设ajax提交操作
      //进行表单数据的序列化
      $.ajax({
        type:"post",
        url:$(this).attr("action"),
        data:$("#myform").serialize(),
        dataType:"json",
        success:function (data){
          if(data.success){
            lightyear.loading('hide');
            lightyear.url('${pageContext.request.contextPath}/clazz');
            lightyear.notify(data.msg, 'success', 500);
          }else {
            lightyear.loading('hide');
            lightyear.notify(data.msg, 'danger', 3000);
          }
        },
        error:function (){
          lightyear.loading('hide');
          lightyear.notify("请求失败请检查！", 'danger', 3000);
        }
      })
    })
  })
</script>
</body>
</html>